<?php
namespace wstmart\admin\controller;
use think\Db;

class Test extends Base
{
    public function getGlobals()
    {
        return $this->checkFun('f', null);
    }

    public function checkFun($a, $b='')
    {
        if (is_null($b))
        {
            return 'hello';
        }
        else if ($b === '')
        {
            return 'world';
        }
        else 
        {
            return 'Yes';
        }
    }

    public function checkarray()
    {
        $number = "1,2,3,0";
        $data = array('fda', 'fdag', 'fdagfda', 'fdag');
        $key = explode(',', $number);
        echo $data[2].' ';
        foreach ($key as $v) {
            echo $data[$v];
        }

        dump($key);
    }

    public function getAnswer()
    {
        $a = true;
        $b = false;
        $d = 0x433;

        dump($a);
        dump($b);
        dump($c);
        dump($d);
    }

    public function getFile()
    {
        $file = request()->file('image');
        $info = $file->move(ROOT_PATH.'public'.DS.'upload');
    }

    public function check()
    {
        $rule = [
            ['accerdname', 'require|max:30', '请输入认证名称'],
            ['accImg', 'require', '请上传图标']
        ];

        $scene = [
           'edit' =>  ['accerdname','accImg'],
           'add'  =>  ['accredName', 'accImg']
        ];
    }

    public function server()
    {
        return json(WSTReturn("删除成功", 1)) ;
    }

    public function getContent()
    {
        $listenUrl = cache('WST_LISTEN_URL');
        dump($listenUrl);
    }

    public function isNull($value='')
    {
        if (is_null($value)){
            echo 'null';
        } else {
            echo "value";
        }
    }

    public function empty2()
    {
        $data = Db::name('datas')->where('catId',3)->column('dataVal');
        dump($data);
        $what = array();
        $what['what'] = $data;
        dump($what);
    }
    public function test()
    {
       return $this->fetch();
    }

    public function array2()
    {
        $data = Db::name('datas')->where('catId',3)->column('dataVal');
        dump($data);
    }

    public function day()
    {
        echo date("Y-m-d H:i:s",strtotime("-".$autoCancelNoPayDays." hours"));
    }

    public function getImage()
    {
        WSTUnuseImage('staffs', 'staffphoto', 6);
    }

    public function opendir($dir)
    {
        $files = array();
        if (is_dir($dir)){
            if ($handle = opendir($dir)) {
                if(false !== ($file = readdir($handle))) {
                    if ($file != '.' && $file != '..') {
                        if (is_dir($dir.'/'.$file)) {
                            $files[$file] = opendir($dir.'/'.$file);
                        } else {
                            $files[] = $file;
                        }
                    }
                }
            }
            fclose($dir);
        }

        return $files;
    }

    public function opedir($dir)
    {
        $file = array();
        if (is_dir($dir)) {
            if ($handle = opendir($dir)) {
                if (false !== ($file = readdir($dir))) {
                    if ($file != '.' && $file != '..') {
                        if ()
                    }
                }
            }
        }
    }
}